package com.bbs.service;

import java.util.List;

import com.bbs.dao.Userdao;
import com.bbs.entity.User;
import com.bbs.util.Page;

public class UserService {
	private Userdao ud = new Userdao();
	
	public User login(String name,String pwd){
		return ud.findByNameAndPwd(name, pwd);
	}
	
	public int register(User u){
		return ud.save(u);
	}

	public User findByName(String name) {
		return ud.findByName(name);
	}

	public User findManager(String name, String pwd) {
		return ud.findManager(name,pwd);
	}

	public List<User> findAllUser(Page p) {
		return ud.findAllUser(p);
	}

	public List<User> findModerators(Page p) {
		return ud.findModerators(p);
	}

	public int delete(int id) {
		return ud.delete(id);
	}

	public int setRole(int uid) {
		return ud.setRole(uid);
	}

	public int update(User u) {
		return new Userdao().update(u); 
	}

	public User findByid(int uid) {
		return ud.findById(uid);
	}
}
